<?php

// change the following paths if necessary
$yii=dirname(__FILE__).'/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

function less_css($filename) {
	return "<link rel='stylesheet/less' href='/less/{$filename}.less' type='text/css' />";
}

function sess($key, $val='#null#') {
	static $start;
	if (!isset($start)) {
		$sess = new CHttpSession();
		$sess->open();
	}
	if ($val == '#null#') {
		$v = $sess[$key];
		return $v;
	} else {
		$sess[$key] = $val;
	}
}

function thumb($file, $width=200, $height=200) {
	$thumb_file = str_replace("uploads/", "uploads/thumb/", $file);
	if (!file_exists($thumb_file)) {
		include_once("protected/phpthumb/ThumbLib.inc.php");
		$thumb = PhpThumbFactory::create($file);
		$thumb->resize($width, $height);
		$thumb->save($thumb_file);
	}
	return $thumb_file;
}

require_once($yii);
Yii::createWebApplication($config)->run();
